<!DOCTYPE html>
<html>

<head>
    <title>ImgOverlay</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body,
        html {
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }

        #allmap {
            width: 100%;
            height: 100%;
        }

        p {
            margin-left: 5px;
            font-size: 14px;
        }
    </style>

    <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=U3q69k0Dv0GCYNiiZeHPf7BS"></script>
    <script src="../dist/inmap.js"></script>
    <script src="data/data.js"></script>
</head>

<body>
    <div id="allmap"></div>
</body>

</html>
<script>
    data.length = 5;
    var map = new inMap.Map({
        id: 'allmap',
        center: [105.403119, 38.028658],
        zoom: {
            value: 5,
            show: true,
            max: 18,
            min: 5
        },
    });


    var img = "./img/bso.svg";
    var img2 = "./img/mark (2).png";

    var overlay = new inMap.ImgOverlay({
        tooltip: {
            show: true,
            // formatter: function (params) {
            //     return params.count;
            // }
            formatter: "{count}"
        },
        style: {
            normal: {
                icon: img,
                width: 40,
                height: 40,
                offsets: {
                    top: "-100%",
                    left: "-50%",
                }
            },
            splitList: [{ //设置区间颜色
                start: 0,
                end: 2,
                icon: img,
            },
            {
                start: 2,
                end: 5,
                icon: img2,

            },
            {
                start: 5,
                end: 7,
                icon: img,
            },
            {
                start: 7,
                icon: img,
            }
            ],
        },
        data: data,
        event: {
            onState(state) {
                // console.log('onState', state);
            },
            onMouseClick(data, event) {
                console.log('onMouseClick', data, event);
            },
            onMouseLeave(data, event) {
                console.log('onMouseLeave', data, event);
            },
            onMouseOver(data) {
                console.log('onMouseOver', data, event);
            }
        }
    });
    overlay.on('init', function () {
        console.log('init');
    });
    function mouseLeave() {
        console.log('mouseLeave2');
    }
    overlay.on('mouseLeave', mouseLeave);

    map.add(overlay);
    overlay.setData(data, (e) => {
        console.log('setData callback');

    });
    var other = [{
        geometry: {
            type: 'Point',
            coordinates: ["126.262876", "43.678846"]
        },
        name: "",
        count: 0 //权重
    }];

    overlay.pushData(other, function () {
        console.log('pushData callback');
        overlay.filter((item) => {
            return item.count > 1;
        });
    });




</script>